// zl123456
// 1234567
const login = document.querySelector('#btn-login');
const form = document.querySelector('.login-form');
//1 --------------------------------------发送登录
async function goLogin(data) {
    let { data: res } = await axios({
      url: '/login',
      method: 'post',
      data,
    });
    //将用户名与token保存到localStorage
    setLocal('username', res.username);
    setLocal('token', res.token);
    pxmu.success('登录成功');
    setTimeout(() => {
      location.href = '../index.html';
    },1000)
}
// 2-----------------------------------------点击登录
login.addEventListener('click', function (e) {
  e.preventDefault();
  let { username, password } = serialize(form, { hash: true, empty: true });
  if (validatData(username, password)) {
    // 发送请求
    goLogin({ username, password });
  } else {
    pxmu.toast('账号或密码错误');
  }
});
